package com.walnut.lom_system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.walnut.lom_system.domain.entity.UserLoginInfo;
import com.walnut.lom_system.service.UserLoginInfoService;
import com.walnut.lom_system.mapper.UserLoginInfoMapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @author chenhetao
* @description 针对表【user_login_info(用户登录的表)】的数据库操作Service实现
* @createDate 2022-01-22 15:02:29
*/
@Service
public class UserLoginInfoServiceImpl extends ServiceImpl<UserLoginInfoMapper, UserLoginInfo>
    implements UserLoginInfoService{

    @Override
    public String getUserAuthorityInfo(Long userId) {
        //TODO
        return new String("111");

//        String authority = "";
//
//        String username = userInfoMapper.queryById(userId).getUsername();
//        //读取缓存是否有对应的权限信息
//        if (redisUtil.hasKey(AUTH_INFO + username)) {
//            authority = (String) redisUtil.get(AUTH_INFO + username);
//        }
//        //没有缓存的情况下：
//        else {
//            List<BarterRoleInfo> barterRoleInfos = roleService.queryRoleByUserId(userId);
//            //获取角色的编码
//            if (barterRoleInfos.size() > 0) {
//                String roleInfo = barterRoleInfos.stream().map(r -> "ROLE_" + r.getCode()).collect(Collectors.joining(","));
//                authority = roleInfo + ",";
//            }
//            //TODO
//            //获取菜单的编码
//
//            List<Long> menuIds = permissionInfoMapper.getNavMenuIds(userId);
//            if (menuIds.size() > 0) {
//                List<BarterPermissionInfo> barterPermissionInfos = permissionInfoMapper.queryByIds(menuIds);
//                String menuPerms = barterPermissionInfos.stream().map(BarterPermissionInfo::getPerms).collect(Collectors.joining(","));
//
//                authority = authority.concat(menuPerms);
//            }
//            //redis存储一小时
//            redisUtil.set(AUTH_INFO + username, authority, DEFAULT_EXPIRATION_TIME);
//            flashUtil.add(AUTH_INFO + username);
//        }
//        return authority;

    }


}




